var SimpleXhrFactory = (function() {
    var standard = {
        CreateXhrObject: function() {
            return new XMLHttpRequest();
        }
    };
    
    var activeXNew = {
        CreateXhrObject: function() {
            return new ActiveXObject('Msxml2.XMLHTTP');
        }
    };
    
    var activeXOld = {
        CreateXhrObject: function() {
            return new ActiveXObject('Microsoft.XMLHTTP');
        }
    };
    
    var testObject;
    try {
        testObject = standard.CreateXhrObject();
        return standard;
    }
    catch(e) {
        try{
            testObject = activeXNew.CreateXhrObject();
            return activeXNew;
        }
        catch(e) {
            try {
                testObject = activeXOld.CreateXhrObject();
                return activeXNew;
            }
            catch(e)
            {
                throw new Error('No XHR object found in this environment.');
            }
        }
    }
})(); 
